package com.pdh.util;

import com.pdh.bean.Message;
import com.pdh.bean.User;

import javax.servlet.http.HttpSession;

/**
 * @Author: 彭德华
 * @Date 2021-08-29 22:19
 */
public class LoginUtil { //根据session获取当前的用户名和用户手机
    public static Message getAdminInfoMsg(HttpSession session) {
        return (Message) session.getAttribute("adminInfoMsg");//号码存储在里面
    }

    public static String getUserPhone(HttpSession session) {
        // TODO : 还没有编写柜子端，未存储任何的录入人信息
        //录入人电话就是微信端登陆者
        User frontUser = (User) session.getAttribute("frontUser");
        return frontUser.getUserPhone();
    }

    public static String getLoginSmsAuthCode(HttpSession session, String userPhone) {
        return (String) session.getAttribute(userPhone);
    }

    public static void setLoginSms(HttpSession session, String userPhone, String code) {
        session.setAttribute(userPhone, code);//使用userPhone存储我们的code值
    }

    public static void setFrontUser(HttpSession session, User frontUser) {
        //user里面含有userPhone
        session.setAttribute("frontUser", frontUser);
    }

    public static User getFrontUser(HttpSession session) {
        return (User) session.getAttribute("frontUser");
    }
}
